package com.hx.er.common.interceptor;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.hx.er.common.system.Constants;
import com.hx.er.common.util.StringUtil;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class UrlInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = -9032347965469098195L;

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		HttpServletRequest request = ServletActionContext.getRequest();
		String token = request.getParameter(Constants.REQUEST_PARAM_TOKEN);
		
		if (StringUtil.isEmpty(token)) {
			return Constants.RESULT_ERROR;
		} else {
			return ai.invoke();
		}
	}
}
